builder-tool: Fix a thinko
authorMatthias Clasen <mclasen@redhat.com>
Wed, 26 Feb 2020 14:59:14 +0000 (09:59 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 26 Feb 2020 15:01:38 +0000 (10:01 -0500)
We can't rely on the pspec for a removed property.
This code worked until I actually removed the properties.

Update the tests to reflect this.

gtk/tools/gtk-builder-tool-simplify.c
testsuite/tools/simplify-data-3to4/grid.expected

index c6b2d5607587b688f7a214f0ead738212b592200..a2b42d135b7c76fc9a1c7a75dbddac6daf9a3e05 100644 (file)
@@ -733,7 +733,8 @@ maybe_rename_property (Element *element, MyParserData *data)
   int i, k, l;
   PropKind kind;
   int prop_name_index = 0;
-  GParamSpec *pspec;
+  GType type;
+  char *canonical_name;
 
   kind = get_prop_kind (element);
 
@@ -751,15 +752,16 @@ maybe_rename_property (Element *element, MyParserData *data)
 
   if (property_name == NULL)
     return;
+  type = g_type_from_name (class_name);
 
-  pspec = get_property_pspec (data, class_name, property_name, kind);
-  if (pspec == NULL)
-    return;
-
+  canonical_name = g_strdup (property_name);
+  g_strdelimit (canonical_name, "_", '-');
+  
   for (k = 0; k < G_N_ELEMENTS (props); k++)
     {
-      if (pspec->owner_type == props[k].type &&
-          strcmp (pspec->name, props[k].property) == 0 &&
+      if (g_type_is_a (type, props[k].type) &&
+          strcmp (canonical_name, props[k].property) == 0 &&
           kind == props[k].kind)
         {
           g_free (element->attribute_values[prop_name_index]);
@@ -787,6 +789,8 @@ maybe_rename_property (Element *element, MyParserData *data)
           break;
         }
     }
+
+  g_free (canonical_name);
 }
 
 static Element *
index 955cf2c541c39ea487be722e812bb00179380fe1..12db5c21e22f99e8a88d6997813f3f931572e826 100644 (file)
@@ -9,7 +9,8 @@
             <property name="active">1</property>
             <property name="can_focus">1</property>
             <property name="receives_default">1</property>
-            <property name="expand">True</property>
+            <property name="vexpand">1</property>
+            <property name="hexpand">1</property>
             <property name="margin-top">10</property>
             <property name="margin-right">10</property>
             <property name="margin-bottom">10</property>